package tech.deepmind.util;

import java.io.IOException;
import java.util.Properties;

import org.springframework.stereotype.Component;

/**
 * 读取proterties
 * @Author: 周军鹏
 * @Date: 2018年12月24日 上午8:59:07
 */
@Component
public class ConfigManager {

	private static Properties properties;
	private static ConfigManager configManager;
	private ConfigManager() {
		properties = new Properties();
		try {
			properties.load(ConfigManager.class.getResourceAsStream("/database.properties"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public synchronized static ConfigManager getInstance() {
		if (configManager == null) {
			configManager = new ConfigManager();
		}
		return configManager;
	}
	
	/**
	 * 根据键获取值
	 * @param key
	 * @return
	 */
	public static String getValue(String key) {
		return properties.getProperty(key);
	}
}
